package com.example.demo.courseUtils;

import okhttp3.*;


import java.io.*;



class Chat {

    static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();

    public static void main(String []args) throws IOException{
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\"app_id\":\"c70093fb-ca59-4c72-be5b-46a1907b15ba\",\"query\":\"你好\",\"conversation_id\":\"1c89bd20-09a3-4f4c-b942-37e726bed75a\",\"stream\":false}");
        Request request = new Request.Builder()
                .url("https://qianfan.baidubce.com/v2/app/conversation/runs")
                .method("POST", body)
                .addHeader("Content-Type", "application/json")
                .addHeader("X-Appbuilder-Authorization", "Bearer bce-v3/ALTAK-dDQqVx4tToYfhO43SfFi9/998aff0b3ed01872fb45399a990ab8283195cd1f")
                .build();
        Response response = HTTP_CLIENT.newCall(request).execute();
        System.out.println(response.body().string());

    }


}